package o;

import java.io.IOException;
import java.util.Arrays;

final class afr {
    private final afp ˊ = new afp();
    private int ˋ;
    private int ˎ = -1;
    private boolean ˏ;
    private final anc ॱ = new anc(new byte[65025], 0);

    afr() {
    }

    public void ˎ() {
        this.ˊ.ˊ();
        this.ॱ.ˏ();
        this.ˎ = -1;
        this.ˏ = false;
    }

    public boolean ˏ(adv o_adv) throws IOException, InterruptedException {
        amm.ˏ(o_adv != null);
        if (this.ˏ) {
            this.ˏ = false;
            this.ॱ.ˏ();
        }
        while (!this.ˏ) {
            int i;
            int i2;
            if (this.ˎ < 0) {
                if (!this.ˊ.ˊ(o_adv, true)) {
                    return false;
                }
                i = this.ˊ.ʻ;
                if ((this.ˊ.ˊ & 1) == 1 && this.ॱ.ॱ() == 0) {
                    i += ॱ(0);
                    i2 = this.ˋ + 0;
                } else {
                    i2 = 0;
                }
                o_adv.ॱ(i);
                this.ˎ = i2;
            }
            i = ॱ(this.ˎ);
            i2 = this.ˎ + this.ˋ;
            if (i > 0) {
                boolean z;
                if (this.ॱ.ˎ() < this.ॱ.ॱ() + i) {
                    this.ॱ.ˏ = Arrays.copyOf(this.ॱ.ˏ, this.ॱ.ॱ() + i);
                }
                o_adv.ˏ(this.ॱ.ˏ, this.ॱ.ॱ(), i);
                this.ॱ.ॱ(i + this.ॱ.ॱ());
                if (this.ˊ.ॱॱ[i2 - 1] != 255) {
                    z = true;
                } else {
                    z = false;
                }
                this.ˏ = z;
            }
            if (i2 == this.ˊ.ʽ) {
                i = -1;
            } else {
                i = i2;
            }
            this.ˎ = i;
        }
        return true;
    }

    public afp ˊ() {
        return this.ˊ;
    }

    public anc ॱ() {
        return this.ॱ;
    }

    public void ˏ() {
        if (this.ॱ.ˏ.length != 65025) {
            this.ॱ.ˏ = Arrays.copyOf(this.ॱ.ˏ, Math.max(65025, this.ॱ.ॱ()));
        }
    }

    private int ॱ(int i) {
        int i2 = 0;
        this.ˋ = 0;
        while (this.ˋ + i < this.ˊ.ʽ) {
            int[] iArr = this.ˊ.ॱॱ;
            int i3 = this.ˋ;
            this.ˋ = i3 + 1;
            int i4 = iArr[i3 + i];
            i2 += i4;
            if (i4 != 255) {
                break;
            }
        }
        return i2;
    }
}
